package com.deyuanyun.pic.pipe.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.domain.Reducer;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * 异管径信息表
 */
public class ReducerVO extends BaseVO<Reducer> {

    // 管道名称
    private String pipeLineName;
    // 异径管编号(自定义编号)
    private String reducerNumber;
    // 绝对距离(m)
    private String mileage;
    // 相对最近参考点
    private String reference;
    // 相对最近参考点距离(m)
    private String referenceDistance;
    // 生产日期
    private String manufacturedDate;
    // 异径管类型
    private String reducerType;
    // 异径管材料
    private String material;
    // 压力等级（MPa）
    private String pressureRating;
    // 出口连接类型
    private String outletConnectionType;
    // 出口直径（mm）
    private String outletDiameter;
    // 出口壁厚（mm）
    private String outletwallthickness;
    // 链接计算结果表
    private String gisId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getReducerNumber() {
        return reducerNumber;
    }

    public void setReducerNumber(String reducerNumber) {
        this.reducerNumber = reducerNumber;
    }

    public String getMileage() {
        return mileage;
    }

    public void setMileage(String mileage) {
        this.mileage = mileage;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public String getReferenceDistance() {
        return referenceDistance;
    }

    public void setReferenceDistance(String referenceDistance) {
        this.referenceDistance = referenceDistance;
    }

    public String getManufacturedDate() {
        return manufacturedDate;
    }

    public void setManufacturedDate(String manufacturedDate) {
        this.manufacturedDate = manufacturedDate;
    }

    public String getReducerType() {
        return reducerType;
    }

    public void setReducerType(String reducerType) {
        this.reducerType = reducerType;
    }

    public String getMaterial() {
        return material;
    }

    public void setMaterial(String material) {
        this.material = material;
    }

    public String getPressureRating() {
        return pressureRating;
    }

    public void setPressureRating(String pressureRating) {
        this.pressureRating = pressureRating;
    }

    public String getOutletConnectionType() {
        return outletConnectionType;
    }

    public void setOutletConnectionType(String outletConnectionType) {
        this.outletConnectionType = outletConnectionType;
    }

    public String getOutletDiameter() {
        return outletDiameter;
    }

    public void setOutletDiameter(String outletDiameter) {
        this.outletDiameter = outletDiameter;
    }

    public String getOutletwallthickness() {
        return outletwallthickness;
    }

    public void setOutletwallthickness(String outletwallthickness) {
        this.outletwallthickness = outletwallthickness;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public void fromDomain(Reducer domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 异径管编号(自定义编号)
        this.reducerNumber = domain.getReducerNumber();
        // 绝对距离(m)
        this.mileage = NumberFormat.format(domain.getMileage(), NumberFormat.FMT_PLACES3);
        // 相对最近参考点
        this.reference = domain.getReference();
        // 相对最近参考点距离(m)
        this.referenceDistance = NumberFormat.format(domain.getReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 生产日期
        this. manufacturedDate = DateFormat.format(domain.getManufacturedDate());
        // 异径管类型
        this.reducerType = CodeUtil.getName(domain.getReducerType());
        // 异径管材料
        this.material = CodeUtil.getName(domain.getMaterial());
        // 压力等级（MPa）
        this.pressureRating = NumberFormat.format(domain.getPressureRating());
        // 出口连接类型
        this.outletConnectionType = CodeUtil.getName(domain.getOutletConnectionType());
        // 出口直径（mm）
        this.outletDiameter = CodeUtil.getName(domain.getOutletDiameter());
        // 出口壁厚（mm）
        this.outletwallthickness = NumberFormat.format(domain.getOutletwallthickness());
        // gis地址
        this.gisId = domain.getGisId();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<ReducerVO> fromDomainList(Page<Reducer> domainList) {
        Page<ReducerVO> list = new Page<ReducerVO>();
        for (Reducer reducer : domainList) {
            ReducerVO reducerVO = new ReducerVO();
            reducerVO.fromDomain(reducer);
            list.add(reducerVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}